import http from '../../util/request.js';
var app = getApp();
Page({
  data: {},
  onLoad: function () {
    var that = this;
    that.getSetting();
  },
  bindGetUserInfo(e) {
    app.util.getUserInfo(function(res){
      wx.reLaunch({
        url: '/weidun_card/pages/index/index'
      })
    });
  },
  // 获取设置
  getSetting: function () {
    var that = this;
    var cache = wx.getStorageSync("setting");
    if (cache) {
      that.setData({
        setting: cache
      });
      var title = cache.title != undefined ? cache.title : '知识卡片';
      wx.setNavigationBarTitle({
        'title': title
      });
    } else {
      http.get('setting', {}).then(function (res) {
        if (res != {}) {
          wx.setStorageSync('setting', res);
          that.setData({
            setting: res
          });
          var title = res.title != undefined ? res.title : '知识卡片';
          wx.setNavigationBarTitle({
            'title': title
          });
        } else {
          that.setData({
            setting: []
          });
        }
      });
    }
  },
})